// app.js
import {getUserInfo} from "./server/login"

App({
  onLaunch() {
    wx.login({
      success(res) {
        if (res.code) {
          //发起网络请求
          // console.log(res.code);
          let data = {
            appid:"wx427dfce71c789246",//在微信开放平台取自己的appid
            secret:"56f5839e1f830581818ec4712a68e935",//在微信开放平台取自己的appid对应的密钥
            js_code:res.code
          }
          getUserInfo(data).then(res => {
            // console.log(res);
            wx.setStorageSync('openid', res.openid)
            wx.setStorageSync('access_token', res.access_token)
            wx.setStorageSync('userInfo', res.user)
          })
        }
      }
    })
  },
  globalData: {

  }
})
